package com.wei.miaosha.util;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * Created by Weizichen on 2018/8/7.
 * desc:MD5加密工具类
 */
public class Md5Util {
    private static final String salt = "1a2b3c4d";

    public static String md5(String str) {
        return DigestUtils.md5Hex(str);
    }

    public static String inputPassFormPass(String inputPass) {
        String str = "" + salt.charAt(2) + salt.charAt(5) + inputPass + salt.charAt(0);
        return md5(str);
    }

    public static String formPassToDBPass(String formPass, String salt) {
        String str = "" + salt.charAt(2) + salt.charAt(5) + formPass + salt.charAt(0);
        return md5(str);
    }

    public static String inputPassToDBPass(String inputPass, String saltDB) {
        String formPass = inputPassFormPass(inputPass);
        String dbPass = formPassToDBPass(formPass, saltDB);
        return dbPass;
    }

    public static void main(String[] args) {
        //String s = inputPassFormPass("123456");//2892335f470e1bedfa6e783a4cf8c6f4
        //String s = formPassToDBPass (inputPassFormPass("123456"),"123456");
        String s = inputPassToDBPass ("123456", "1a2b3c4d");//0e32b425973ea5603b70268ad68d8334
        System.out.println(s);
    }
}
